window.onload=function(){

    var app=new Vue({
        el:"#app",
        data:{
            rolearray:[],
            arr:[],
            checkList:[],
            beisysuser:{
                username:"",
                phone:"",
                email:"",
                password:"",
                checkList:[],
                passwordtwo:""
            }
        },
        methods:{
            inisrole(){
                //初始化数据
                methodaxios.get(null,"/role/querys",rep=>{
                    this.rolearray=rep.data
                })
            },
            sysadd(){
                if(isBlank(this.beisysuser.username)){
                    layer.msg("请输入用户名");
                    return false;
                }
                //如果密码不为空
                if(isBlank(this.beisysuser.password)){
                    layer.msg("请输入密码");
                    return false;
                }
                if(this.beisysuser.password.length<6){
                    layer.msg("请正确输入密码");
                    return ;
                }
                if(isNotPhone(this.beisysuser.phone)){
                    layer.msg("请正确输入电话号码");
                    return ;
                }
                if(isNotEmail(this.beisysuser.email)){
                    layer.msg("请正确输入邮箱");
                    return ;
                }
                if(this.beisysuser.password!=this.beisysuser.passwordtwo){
                    layer.msg("两次密码不一致");
                    return ;
                }
                this.beisysuser.password=MD5(this.beisysuser.password);
                methodaxios.post("/sys/adduser",this.beisysuser,(rep)=>{
                    if(rep.data.code==="1000"){
                        layer.msg(rep.data.msg);
                    }
                    if(rep.data.code==="200"){
                        x_admin_close()
                       window.location="/sys/list"
                    }
                })
            }
        },
        mounted() {
            this.inisrole();
        }

    })


}